#include "test.h"
#include "../../common/include/std.h"
#include "../../common/file/basic.h"
#include "../../common/encode/hex.h"

int Test()
{
	char caOut[MAX_PATH];

	realpath("1.txt", caOut);

	cout << caOut << endl;

	return 0;
}

int TestHex()
{
	int iResult;
	STD_BUFFER bufTest,bufDecode;
	string strEncode;

	for (int i = 0; i < 256; i++)
	{
		bufTest.push_back(i);
	}

	iResult = HexEncode(bufTest, strEncode);
	cout << iResult<<" " << strEncode << endl;

	iResult = HexDecode(strEncode, bufDecode);
	cout << iResult << endl;

	return 0;
}

int TestFile()
{
	int iResult;

	STD_BUFFER bufTest, bufRead;
	char caTest[10] = "12345678";

	bufTest.resize(100, 1);
	iResult = FILEAPI_WriteFile("D:\\tmp\\test.dat", bufTest);
	cout << "FILEAPI_WriteFile ret " << iResult << endl;

	iResult = FILEAPI_ReadFile("D:\\tmp\\test.dat", bufRead);
	cout << "FILEAPI_ReadFile ret " << iResult << endl;
	cout << "bufRead " << bufRead.size() << " " << (int)bufRead[0] << endl;;

	return 0;
}

int TestTime()
{
	auto t1 = STD_NOW;
	STD_SLEEP_MS(500);
	auto t2 = STD_NOW;
	auto t = t2 - t1;
	cout << STD_MILLISECOND(t) << endl;
	return 0;
}
